﻿namespace Ping.App
{
	public sealed class SettingsService
		: StorageService<Settings>
	{
		/// <summary>
		/// The current settings of the application.
		/// The one and only true pattern of software engineering.
		/// </summary>
		public static Settings Settings;

		protected override string FileName
		{
			get { return "Settings.xml"; }
		}

		protected override Settings CreateDefault()
		{
			return new Settings
			       	{
			       		AppServer = "192.168.11.2",
			       		AppPort = 1337,
			       	};
		}

		/// <summary>
		/// Saves the settings to disk.
		/// </summary>
		public static void Store()
		{
			var tmp = new SettingsService();
			tmp.Save(Settings);
		}

		/// <summary>
		/// Restores the settings from disk.
		/// </summary>
		public static void Restore()
		{
			var tmp = new SettingsService();
			Settings = tmp.Load();
		}
	}
}